<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>过滤器</title>
  <script src="https://cdn.bootcdn.net/ajax/libs/lodash.js/4.17.21/lodash.min.js"></script>
  <script src="../vue.js"></script>
</head>
<body>
  <div id="app">
    性别：{{ gender | fg('孩儿', '!') }}
    <div>
      <button @click="change">change</button>
    </div>
    <div>
      {{msg}}
    </div>
    <ul>
      <li v-for="value in list2">{{value}}</li>
    </ul>
  </div>
  <script type="module">
    new Vue({
      el: '#app',

      data: {
        gender: 0,
        msg: 'hello',
        list: [
          'a', 'b', 'c'
        ]
      },

      filters: {
        fg(value, arg, arg2) {
          console.log('filter')
          return value === 0 ? '男' + arg + arg2 : '女' + arg + arg2
        },
        fga(value, arg) {
          return value + arg
        }
      },
      
      computed: {
        cgengder() {
          console.log('computed')
          return this.gender === 0 ? '男' : '女'
        },
        list2() {
          return this.list.map(value => {
            return _.repeat(value, 3)
          })
        }
      },

      methods: {
        change() {
          // this.gender = 0
          this.msg = 'world'
        }
      },
    })
  </script>
</body>
</html>